import axiosServer from '@/api/request'
/**
 * 资源
 * @param {*} menuId
 * @returns
 */
export const RequestResource = (menuId: number) => {
	return axiosServer({
		method: 'get',
		url: '/api/system/resource/list',
		params: { menuId }
	})
}

/**
 * 资源
 * @param {*} menuId
 * @returns
 */
export const RequestAuthResource = (roleId: number) => {
	return axiosServer({
		method: 'get',
		url: '/api/system/resource/auth',
		params: { roleId }
	})
}

/**
 * 资源权限
 */
export const RequestReourceAuthor = (roleId: number) => {
	return axiosServer({
		method: 'get',
		url: '/api/system/resource',
		params: {
			roleId
		}
	})
}

/**
 * 所有资源权限
 */
export const RequestReourceAll = () => {
	return axiosServer({
		method: 'get',
		url: '/api/system/resource/all'
	})
}
/**
 * 添加资源
 */
export const RequestAddResource = ({ menuId, name, code, num }) => {
	return axiosServer({
		method: 'post',
		url: '/api/system/addmenu',
		data: {
			roleId: 1,
			parentId: menuId,
			nodeType: 2,
			menuName: name,
			path: code,
			icon: ''
		}
	})
}

export const resourceApi = {
	RequestResource,
	RequestAuthResource,
	RequestReourceAuthor,
	RequestReourceAll,
	RequestAddResource
}
